package top.zhaoyuliu.logbook.client.link;

import javax.annotation.PostConstruct;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.stereotype.Service;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;
import top.zhaoyuliu.logbook.client.constant.Const;

/**
 * Copyright © 2021 Arain. All rights reserved.
 *
 * @Title: TrackRequestInterceptor.java
 * @Prject: logbook-client
 * @Package: top.zhaoyuliu.logbook.client.link
 * @Description: <功能详细描述>
 * @author: Arain
 * @date: 2021年2月5日 上午9:56:50
 * @version: V1.0
 */
@Service
@Slf4j
@ConditionalOnClass(feign.Feign.class)
public class TrackRequestInterceptor implements RequestInterceptor {

	@PostConstruct
	public void init() {
		log.info("feign链路启用");
	}

	@Override
	public void apply(RequestTemplate template) {
		template.header(Const.TRACK, LinkThreadLocal.traceID.get());
	}

}
